﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <title>IMES</title>
    <link href="~/hiprint/css/hiprint.css" rel="stylesheet" />
    <link href="~/hiprint/css/print-lock.css" rel="stylesheet" />

    <script src="https://cdn.jsdeliver.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <script src="~/hiprint/polyfill.min.js"></script>
    <script src="~/hiprint/hiprint.bundle.js"></script>
    <script src="~/hiprint/plugins/jsbarcode.all.min.js"></script>
    <script src="~/hiprint/plugins/qrcode.js"></script>
    <script src="~/hiprint/plugins/jquery.hiwprint.js"></script>
</head>
<body>
    @* <button class="layui-btn layui-btn-primary layui-border-blue" onclick="PrintThis()" style="margin-left:330px;margin-top:100px">打印</button>
    <div id="templateDesignDiv" style="margin-left:auto;margin-right:auto;width:800px;margin-top:-40px"></div> *@
    <script>
        $(function () {
            print();
            PrintThis();
        })
        hiprint.init();
        var hiprintTemplate;
        var obj = {
            "panels": [{ 
                "index": 0, "paperType": "B5", "height": 176, "width": 250, "paperHeader": 43.5, "paperFooter": 498.8976377952756, 
                "printElements": [{ "options": { "left": 210, "top": 6, "height": 36, "width": 208.5, "title": "装配工单明细", "fontWeight": "900", "letterSpacing": 9, "color": "#d45759", "textAlign": "center" }, "printElementType": { "type": "text" } }, 
                { "options": { "left": 31.5, "top": 55.5, "height": 15, "width": 201, "title": "单据编号:", "field": "assemblyNumber", "testData": "93487598734", "fontWeight": "bolder", "letterSpacing": 4.5 }, "printElementType": { "type": "text" } }, { "options": { "left": 30, "top": 87, "height": 27, "width": 120, "title": "制单人:", "field": "createId", "testData": "超级管理员", "fontWeight": "bolder" }, "printElementType": { "type": "text" } }, { "options": { "left": 231, "top": 88.5, "height": 16.5, "width": 172.5, "title": "创建时间:", "field": "createDate", "testData": "2024-12-25 16:00:10", "fontWeight": "bolder" }, "printElementType": { "type": "text" } }], "paperNumberLeft": 678, "paperNumberTop": 476 }] 
        }

        console.log(obj);
        hiprintTemplate = new hiprint.PrintTemplate({
            template: obj,
        });
        hiprintTemplate.design('#templateDesignDiv', { grid: true });
        function print() {
            var thisNo = location.href.split('=')[1];
            console.log(thisNo);
            $.ajax({
                url: '',
                data: JSON.stringify({ ProNo: thisNo }),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    if (res.objects != null) {
                        let html = hiprintTemplate.getHtml(res.objects);
                        $("#templateDesignDiv").html(html);
                    }
                }
            })
            $("#templateDesignDiv").empty();
        }
        function PrintThis() {
            var thisNo = location.href.split('=')[1];
            console.log(thisNo);
            $.ajax({
                url: '',
                data: JSON.stringify({ ProNo: thisNo }),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    if (res.objects != null) {
                        hiprintTemplate.print(res.objects);
                    }
                }
            })
        }
    </script>
</body>
</html>